// 题目链接：https://leetcode.cn/problems/search-insert-position/

class Solution
{
public:
    int searchInsert(vector<int> &nums, int target)
    {
        int l = -1, r = nums.size();
        int mid;
        while (l + 1 < r)
        {
            mid = (l + r) / 2;
            if (nums[mid] < target)
                l = mid;
            else
                r = mid;
        }

        return r;
    }
};